package com.itheima.mapper.store;

import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface PieAgeMapper {


    @Select("SELECT\n" +
            "name,\n" +
            "COUNT(*) value\n" +
            "FROM\n" +
            "(SELECT \n" +
            "CASE\n" +
            "WHEN age<21 THEN '青年'\n" +
            "WHEN age<35 THEN '中年'\n" +
            "WHEN age<60 THEN '老年'\n" +
            "ELSE '暮年'\n" +
            "END name\n" +
            "FROM \n" +
            "member\n" +
            ") a\n" +
            "GROUP BY NAME\n" +
            "ORDER BY FIELD(NAME,'青年','中年','老年','暮年')")
    List<Map<String, Object>> findAgeCount();
}
